package com.irdstudio.tdp.console.api.rest;

import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.irdstudio.tdp.console.service.facade.OsrvIsrvEvalService;
import com.irdstudio.tdp.console.service.vo.OsrvIsrvEvalVO;
import com.irdstudio.sdk.beans.core.vo.ResponseData;
import com.irdstudio.sdk.ssm.web.AbstractController;

@RestController
@RequestMapping("/api")
public class OsrvIsrvEvalController extends AbstractController  {
	
	@Autowired
	@Qualifier("osrvIsrvEvalServiceImpl")
	private OsrvIsrvEvalService osrvIsrvEvalService;

	
	/**
	 * 列表数据查询
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping(value="/osrv/isrv/evals", method=RequestMethod.POST)
	public @ResponseBody ResponseData<List<OsrvIsrvEvalVO>> queryOsrvIsrvEvalAll(
			OsrvIsrvEvalVO vo) {		
		List<OsrvIsrvEvalVO> outputVo = osrvIsrvEvalService.queryAllOwner(vo);
		return getResponseData(outputVo);
		
	}

	/**
	 * 列表数据查询
	 * @param page
	 * @param size
	 * @return
	 */
	@RequestMapping(value="/osrv/isrv/evals/tableInit", method=RequestMethod.POST)
	public @ResponseBody ResponseData<Boolean> queryOsrvIsrvEvalAllAndCheckInit(
							@RequestParam("appModelId") String appModelId,
							@RequestBody OsrvIsrvEvalVO vo) {
		// 新选择的领域服务调用 检查是否需要初始化参数列表
		List<OsrvIsrvEvalVO> outputVo = osrvIsrvEvalService.queryAllOwnerCheckInit(appModelId, vo);

		return getResponseData(CollectionUtils.isNotEmpty(outputVo));

	}
	
	/**
	 * 根据主键查询详情
	 * @return
	 */
	@RequestMapping(value="/osrv/isrv/eval/{recordKeyid}", method=RequestMethod.GET)
	public @ResponseBody ResponseData<OsrvIsrvEvalVO> queryByPk(@PathVariable("recordKeyid") String recordKeyid) {		
		OsrvIsrvEvalVO inVo = new OsrvIsrvEvalVO();
				inVo.setRecordKeyid(recordKeyid);
		OsrvIsrvEvalVO outputVo = osrvIsrvEvalService.queryByPk(inVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键删除信息
	 * @param osrvIsrvEval
	 * @return
	 */
	@RequestMapping(value="/osrv/isrv/eval", method=RequestMethod.DELETE)
	public @ResponseBody ResponseData<Integer> deleteByPk(@RequestBody OsrvIsrvEvalVO inOsrvIsrvEvalVo) {		
		int outputVo = osrvIsrvEvalService.deleteByPk(inOsrvIsrvEvalVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 根据主键更新信息
	 * @param inOsrvIsrvEvalVo
	 * @return
	 */
	@RequestMapping(value="/osrv/isrv/eval", method=RequestMethod.PUT)
	public @ResponseBody ResponseData<Integer> updateByPk(@RequestBody OsrvIsrvEvalVO inOsrvIsrvEvalVo) {		
		int outputVo = osrvIsrvEvalService.updateByPk(inOsrvIsrvEvalVo);
		return getResponseData(outputVo);
		
	}
	
	/**
	 * 新增数据
	 * @param inOsrvIsrvEvalVo
	 * @return
	 */
	@RequestMapping(value="/osrv/isrv/eval", method=RequestMethod.POST)
	public @ResponseBody ResponseData<Integer> insertOsrvIsrvEval(@RequestBody OsrvIsrvEvalVO inOsrvIsrvEvalVo) {
		int outputVo = osrvIsrvEvalService.insertOsrvIsrvEval(inOsrvIsrvEvalVo);
		return getResponseData(outputVo);
		
	}
}
